package chessman;

import java.util.ArrayList;

import javax.swing.ImageIcon;

public class Knight extends Chessman {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6027390287014330770L;
	private static Knight instanceA = new Knight(new ImageIcon("Resources/Images/Knight-icon.png"),0);
	private static Knight instanceB = new Knight(new ImageIcon("Resources/Images/Knight-blue-icon.png"),1);

	public static Knight getInstanceTeamA() {
		return instanceA;
	}
	public static Knight getInstanceTeamB() {
		return instanceB;
	}

	public Knight(ImageIcon icon,int team) {
		super(icon, team);
		// TODO Auto-generated constructor stub
	}

	

	@Override
	public ArrayList<String> canMove(Chessman[] arrayChess) {
		ArrayList<String> moves = new ArrayList<String>();
		String temp = null;
		if (col - 2 >= 0) {
			if (row - 1 >= 0){
				temp = this.cols[col - 2] + this.rows[row - 1];
				moves.add(temp);
			}
			if (row + 1 <= 7){
				temp = this.cols[col - 2] + this.rows[row + 1];
				moves.add(temp);
			}		
		}
		if (col - 1 >= 0) {
			if (row - 2 >= 0){
				temp = this.cols[col - 1] + this.rows[row - 2];
				moves.add(temp);
			}
			if (row + 2 <= 7){
				temp = this.cols[col - 1] + this.rows[row + 2];
				moves.add(temp);
			}		
		}
		if (col + 2 <= 7) {
			if (row - 1 >= 0){
				temp = this.cols[col + 2] + this.rows[row - 1];
				moves.add(temp);
			}
			if (row + 1 <= 7){
				temp = this.cols[col + 2] + this.rows[row + 1];
				moves.add(temp);
			}		
		}
		if (col + 1 <= 7) {
			if (row - 2 >= 0){
				temp = this.cols[col + 1] + this.rows[row - 2];
				moves.add(temp);
			}
			if (row + 2 <= 7){
				temp = this.cols[col + 1] + this.rows[row + 2];
				moves.add(temp);
			}		
		}
		return moves;
	}

}
